using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.RecipeFramework;
using System.Collections;
using Microsoft.Practices.RepositoryFactory.CodeGeneration.ObjectModel;
using Microsoft.Practices.RepositoryFactory.CommonHelpers;
using System.Xml;

namespace Microsoft.Practices.RepositoryFactory.Actions
{
    public class PersistsRepositoryOperationsAction : ConfigurableAction
    {
        ArrayList entities;
        XmlDocument recipeState;

        /// <summary>
        /// Gets or sets the entites to generate.
        /// </summary>
        /// <value>Entities.</value>
        [Input(Required = true)]
        public ArrayList Entities
        {
            get { return entities; }
            set { entities = value; }
        }

        [Input(Required = true)]
        public XmlDocument RecipeState
        {
            get { return recipeState;  }
            set { recipeState = value;  }
        }

        public override void Execute()
        {
            EntitySerializerHelper serializer = new EntitySerializerHelper(RecipeState);
            serializer.PersistEntityMappings(entities);
        }

        public override void Undo()
        {
            throw new Exception("The method or operation is not implemented.");
        }
    }
}
